﻿Imports BUS

Public Class frmQuenMatKhau

    Private Sub frmQuenMatKhau_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        frmDangNhap.Show()
    End Sub

    Private Sub frmQuenMatKhau_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cbbTenMien.Items.Add("yahoo.com")
        cbbTenMien.Items.Add("yahoo.com.vn")
        cbbTenMien.Items.Add("gmail.com")
        cbbTenMien.Items.Add("student.hcmus.edu.vn")
        cbbTenMien.Items.Add("fit.hcmus.edu.vn")
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub

    Private Sub btnGuiMail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuiMail.Click
        Dim email = txtEmail.Text + "@" + cbbTenMien.Text

        If TaiKhoan_BUS.kiemTraEmailTonTai(email) = False Then
            MessageBox.Show("email không tồn tại")
            Exit Sub
        End If

        Dim pass = ""
        Dim chars() As String = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", _
         "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "X", _
     "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"}

        For i As Integer = 0 To 5
            pass += chars(Int(Rnd() * 62))
        Next

        Dim result = ""
        Try
            sendMail.SendEmailFromGmailMail(email, pass, result)
            TaiKhoan_BUS.updateMatKhau(pass)
            MessageBox.Show(result)
        Catch ex As Exception

        End Try
        
    End Sub



End Class